package com.lv.hechuang.utils;

import android.os.CountDownTimer;

/**
 * 短信倒计时
 * Created by Administrator on 2017/8/11.
 */

public class CountDownTimerUtils extends CountDownTimer {
    private CountDownTimerListener countDownTimerListener;

    public interface CountDownTimerListener {
        void onTimeTickListener(long millisUntilFinished);

        void onTimeFinishListener();
    }

    public void setCountDownTimerListener(CountDownTimerListener countDownTimerListener) {
        this.countDownTimerListener = countDownTimerListener;
    }

    public CountDownTimerUtils(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    @Override
    public void onTick(long millisUntilFinished) {
//        textView.setClickable(false);
//        textView.setText(millisUntilFinished / 1000 + "s后重发");  //设置倒计时时间
//        textView.setBackgroundResource(R.drawable.gray_ebe3df_radius_2_shap);
//        textView.setTextColor(context.getResources().getColor(R.color.color_8D9094));
        if (countDownTimerListener != null) {
            countDownTimerListener.onTimeTickListener(millisUntilFinished);
        }
    }

    @Override
    public void onFinish() {
        if (countDownTimerListener != null) {
            countDownTimerListener.onTimeFinishListener();
        }
    }
}
